log using "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/Data_analysis_print.smcl", replace

*************************************
* ANALYSIS 
*************************************

clear all

* Set the Path
cd "/Users/Didac/Dropbox/Shared/Replication Files/IO_Replication/"

*************************************
* TABLE 1 
*************************************

* All details in article

*************************************
* TABLE 2
*************************************

* All details in article

*************************************
* TABLE 3
*************************************

* Total number of years and mean duration of war while credit flows with standard deviation: The code produces this result: 222 inter-state war-years, lasting on average 2.32 years (1.87 s.d.) --> Table 3
	use "country_year_format_main.dta", clear
	keep if external_war == 1
	keep if stop_4y == 0
	bysort country war_number: gen mean_duration_credit = _n
	sum mean_duration_credit
	
* Total number of year and mean duration of war while credit stops with standard deviation: The code produces this result: 243 inter-state war-years, lasting on average 2.25 years (1.51 s.d.) --> Table 3
	use "country_year_format_main.dta", clear
	keep if external_war == 1
	keep if stop_4y == 1
	bysort country war_number: gen mean_duration_no_credit = _n
	sum mean_duration_no_credit


* Total number of war-years: This code produces the result: Obs = 465 war-years (the remaining descriptives have no substantive meaning) --> Table 3
	use "country_year_format_main.dta", clear
	keep if external_war == 1
	egen count_war_number = group(war_number)
	sum count_war_number
	* % of war-years while credit flows = 100*(222/465) = 47.74% --> Table 3
	* % of war-years while credit stops = 100*(243/465) = 52.25% --> Table 3


* Total number of years and mean duration of war while credit flows with standard deviation: The code produces this result: 313 inter-state and secessionist war-years, lasting on average 2.23 years (1.73 s.d.) --> Table 3
	use "country_year_format_secession.dta", clear
	keep if external_war == 1
	keep if stop_4y == 0
	gen war_number_both = war_number
	* Add only non-contemporaneous secessionist war
	replace war_number_both = sec_war_number if war_number==.
	bysort country war_number_both: gen mean_duration_credit = _n
	sum mean_duration_credit
	
* Total Number of Year and mean duration of war while credit stops with standard deviation: The code produces this result: 2.29 inter-state/secessionist war-years, lasting on average 2.29 years (1.58 s.d.) --> Table 3
	use "country_year_format_secession.dta", clear
	keep if external_war == 1
	keep if stop_4y == 1
	gen war_number_both = war_number
	* Add only non-contemporaneous secessionist war
	replace war_number_both = sec_war_number if war_number==.
	bysort country war_number_both: gen mean_duration_credit = _n
	sum mean_duration_credit


* Total Number of War-Years: This code produces this result: This code produces the result: Obs = 615 war-years (the remaining descriptives have no substantive meaning) --> Table 3
	use "country_year_format_secession.dta", clear
	keep if external_war == 1
	gen war_number_both = war_number
	* Add only non-contemporaneous secessionist war
	replace war_number_both = sec_war_number if war_number==.
	egen count_war_number = group(war_number_both)
	sum count_war_number
	* % of war-years while credit flows = 100*(313/615) = 50.89% --> Table 3
	* % of war-years whole credit stops = 100*(302/615) = 49.11% --> Table 3
	


*************************************
* TABLE 4 
*************************************

clear all

use "data_for_main_analysis.dta", clear 

* Column 1
reg avg_pit_95_05 years_external i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", replace dec(3) 

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region  colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 3
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 4
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert net_war_abroad if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 5
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert cloddeathsqkm if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 6
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert mean_duration if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 7
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert total_years_default if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 8
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ethfrac if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 9
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert n_civil if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 

* Column 10
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ww1 if country!="United Kingdom", r
outreg2 using "Tables/table_4.tex", append dec(3) 



*************************************
* TABLE 5
*************************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom" & greatpower ==0, r
outreg2 using "Tables/table_5.tex", replace dec(3) 

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if greatpower ==0 & country!="United Kingdom" & country!= "Netherlands" & country!= "United States of America" & country != "Canada" & country!="Japan", r
outreg2 using "Tables/table_5.tex", append dec(3) 


********** Notice Dataset Change

use "data_for_main_analysis_sovereign.dta", clear

* Column 3
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_5.tex", append dec(3)

* Column 4
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_5.tex", append dec(3)

********** Notice Dataset Change

use "data_for_main_analysis_secession.dta", clear

* Column 5 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_5.tex", append dec(3)

* Column 6
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_5.tex", append dec(3)


********** Notice Dataset Change

use "data_for_main_analysis.dta", clear 

* Column 7
reg taxstaff_04_10  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert  if country!="United Kingdom", r
outreg2 using "Tables/table_5.tex", append dec(3)

* Column 8
reg taxstaff_04_10  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower  if country!="United Kingdom", r
outreg2 using "Tables/table_5.tex", append dec(3)



*************************************
* TABLE 6
*************************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_6.tex", replace dec(3)

* Column 2 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist05v3 if country!="United Kingdom", r
outreg2 using "Tables/table_6.tex", append dec(3)

* Column 3 
reg avg_pit_95_05 total_years_ongoingwar_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_6.tex", append dec(3)

* Column 4
reg avg_pit_95_05 total_years_ongoingwar_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_6.tex", append dec(3)

* Column 5
reg avg_pit_95_05 total_years_ongoingwar_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist05v3 if country!="United Kingdom", r
outreg2 using "Tables/table_6.tex", append dec(3)



*************************************
* TABLE 7
*************************************

use "data_for_COW_full_sample.dta", clear

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_7.tex", replace dec(3)

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower net_victory census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_7.tex", append dec(3)


********** Notice Dataset Change

use "data_for_COW_noninitiators_sample.dta", clear

* Column 3
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_7.tex", append dec(3)

* Column 4
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower net_victory census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_7.tex", append dec(3)


****************************************
* TABLE 8
****************************************

********** Notice Dataset Change

use "data_for_main_analysis.dta", clear 

* Column 1
probit census_1914  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_8.tex", replace dec(3) 

* Column 2
probit census_1914  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert statehis if country!="United Kingdom" , r
outreg2 using "Tables/table_8.tex", append dec(3) 


* Column 3 (but first, # years since 1816 not having adopted a modern census)
gen late_census = first_census - 1816
reg late_census  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert statehis if country!="United Kingdom" , r
outreg2 using "Tables/table_8.tex", append dec(3) 

* Column 4
reg late_census  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert statehis greatpower  if country!="United Kingdom" , r
outreg2 using "Tables/table_8.tex", append dec(3) 

* Column 5
gen ln_primary_1820 = ln(1+primary_1820) 
reg primary_1915  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ln_primary_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_8.tex", append dec(3) 

* Column 6
reg primary_1915  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ln_primary_1820 state if country!="United Kingdom", r
outreg2 using "Tables/table_8.tex", append dec(3) 

* Column 7
reg primary_1915  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ln_primary_1820 greatpower statehis  if country!="United Kingdom", r
outreg2 using "Tables/table_8.tex", append dec(3) 


*****************************************
* FIGURE 1 
*****************************************

********** Notice Dataset Change

use "stone_data_1865_1914.dta", clear

gen scaled_grand_tot = grand_tot/1000

generate upper = 220
twoway  (area upper year if year>=1865 & year<=1869,  fcolor(gs12) lcolor(gs15) lwidth(none)) (area upper year if year>=1872 & year<=1877, fcolor(gs12) lcolor(gs15) lwidth(none)) (area upper year if year>=1890 & year<=1894,  fcolor(gs12) lcolor(gs15) lwidth(none)) (area upper year if year>=1910 & year<=1914,  fcolor(gs7) lcolor(gs7) lwidth(none)) (line scaled_grand_tot year,  lcolor(black) lwidth(medthick) lpattern(solid)  ytitle(Millions of current Pounds Sterling) xlabel(1865(5)1915)  graphregion(color(white))), legend(off)
		
graph export "Figures/Figure_1.pdf", replace

*****************************************
* FIGURE 2 
*****************************************

********** Notice Dataset Change

use "data_for_main_analysis.dta", clear 

quiet reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom" , r

avplot total_years_war_and_stop_4y, mlabel(country) xtitle("Residuals from Regressing" "# Years at War while Credit Stops on Controls") ytitle("Residuals from Regressing" "PIT as % of GDP on Controls") graphregion(color(white))  mcolor(black) mlabel(country) mlabcolor(black)   xtitle(, size(large))  ytitle(, size(large))

graph export "Figures/Figure_2a.pdf", replace

avplot total_years_war_and_flow_4y, mlabel(country) xtitle("Residuals from Regressing" "# Years at War while Credit Flows on Controls") ytitle("Residuals from Regressing" "PIT as % of GDP on Controls") graphregion(color(white)) mcolor(black) mlabel(country) mlabcolor(black)   xtitle(, size(large))  ytitle(, size(large))

graph export "Figures/Figure_2b.pdf", replace

***********************************************
* FIGURE 3
***********************************************

use "data_for_main_analysis.dta", clear

* Notice slight change in variable labels because of formatting requirements
label variable total_years_war_and_flow_4y "#War-years between 1816 and 1913 while Credit Flowed"
label variable total_years_war_and_stop_4y "#War-years between 1816 and 1913 while Credit Stopped"

* Required Stata package: "coefplot"

* Note: Basic controls due to low N (furthed details in manuscript)

eststo _1950: quiet reg nontrade_tax_45_55 total_years_war_and_flow_4y total_years_war_and_stop_4y colony_any pop_dens_1820 oil_producer near_coast greatpower  if country!="United Kingdom" , r

eststo _1960: quiet reg nontrade_tax_55_65 total_years_war_and_flow_4y total_years_war_and_stop_4y  pop_dens_1820 oil_producer colony_any near_coast greatpower if country!="United Kingdom" , r

eststo _1970: quiet reg nontrade_tax_65_75 total_years_war_and_flow_4y total_years_war_and_stop_4y  pop_dens_1820 oil_producer colony_any near_coast greatpower if country!="United Kingdom" , r

eststo _1980: quiet reg nontrade_tax_75_85 total_years_war_and_flow_4y total_years_war_and_stop_4y  pop_dens_1820 oil_producer colony_any near_coast greatpower if country!="United Kingdom" , r

eststo _1990: quiet reg nontrade_tax_85_95 total_years_war_and_flow_4y total_years_war_and_stop_4y pop_dens_1820 oil_producer colony_any  near_coast greatpower if country!="United Kingdom" , r

coefplot _1950 || _1960 || _1970 || _1980 || _1990, keep( total_years_war_and_flow_4y total_years_war_and_stop_4y) yline(0, lcolor(gs13) lpattern(dash)) levels(90) bycoefs vertical xlabel(, angle(forty_five))  ytitle("Marginal Effect on" "Nontrade Tax Revenue")  subtitle(, size(small)) 

graph export "Figures/Figure_3.pdf", replace


*****************************
* FIGURE 4
*****************************

use "data_for_main_analysis.dta", clear

* Notice slight change in variable labels because of formatting requirements
label variable total_years_war_and_flow_4y "#War-years 1816-1913 while Credit Flowed"
label variable total_years_war_and_stop_4y "#War-years 1816-1913 while Credit Stopped"

* Short-Run Executive Constraints (Left)
eststo short_run: quiet reg exconst_1900_13  total_years_war_and_stop_4y total_years_war_and_flow_4y pop_dens_1820 near_coast oil_producer exconst_1800_1830 colony_any greatpower if country!="United Kingdom", r

coefplot short_run, keep(total_years_war_and_stop_4y total_years_war_and_flow_4y) yline(0, lcolor(gs13) lpattern(dash)) levels(90) vertical ytitle("Marginal Effect on Executive Constraints" "in 1900-1913") graphregion(color(white)) xlabel(, labsize(small))

graph export "Figures/Figure_4_a.pdf", replace

* Long-Run Executive Constraints (Right)
eststo long_run: quiet reg exconst_95_05  total_years_war_and_stop_4y total_years_war_and_flow_4y pop_dens_1820 near_coast oil_producer exconst_1800_1830 colony_any greatpower if country!="United Kingdom", r

coefplot long_run, keep(total_years_war_and_stop_4y total_years_war_and_flow_4y) yline(0, lcolor(gs13) lpattern(dash)) levels(90) vertical ytitle("Marginal Effect on Executive Constraints" "in 1900-1913") graphregion(color(white)) xlabel(, labsize(small))

graph export "Figures/Figure_4_b.pdf", replace


****************************
****************************
****************************
****************************
****************************
****************************
*******
*******   APPENDIX  ********
*******
****************************
****************************
****************************
****************************
****************************
****************************


*************************************
* TABLE A-1
*************************************

use "data_for_main_analysis.dta", clear 

**** Column 1
reg non_augmented_pit_95_05  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower  if country!="United Kingdom", r
outreg2 using "Tables/table_A_1.tex", replace dec(3) 

**** Column 2
reg avg_pit_90_00  total_years_war_and_stop_4y total_years_war_and_flow_4y  i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower    if country!="United Kingdom", r
outreg2 using "Tables/table_A_1.tex", append dec(3) 

**** Column 3
reg avg_pit_00_10  total_years_war_and_stop_4y total_years_war_and_flow_4y  i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower  if country!="United Kingdom", r
outreg2 using "Tables/table_A_1.tex", append dec(3) 


*************************************
* TABLE A-2
*************************************

* List of inter-state wars drawn from Wimmer and Min 2009

*************************************
* TABLE A-3
*************************************

* Refer to manuscript

*************************************
* TABLE A-4
*************************************

* Refer to manuscript

*************************************
* TABLE A-5
*************************************

* List of secessionist wars drawn from Wimmer and Min 2009

*************************************
* TABLE A-6
*************************************

* Required Stata package: sutex. Then, copy-paste parts 1, 2, and 3 to a .tex file to produce Table A-6.

use "data_for_main_analysis.dta", clear 

* Part 1. War-credit variables created with Wimmer-Min Data + Sudden Stops
sutex avg_pit_95_05 avg_vat_95_05 taxstaff_04_10 census_1820 census_1914 first_census primary_1915 ln_rail_km_1913 nontrade_tax_45_55 nontrade_tax_55_65 nontrade_tax_65_75  nontrade_tax_75_85 nontrade_tax_85_95 years_external    total_years_war_and_stop_4y total_years_war_and_flow_4y total_years_ongoingwar_stop_4y oil_producer n_civil pop_dens_1820 greatpower cloddeathsqkm net_war_abroad ethfrac near_coast  desert rugged land_area_scaled statehist05v3 finan_plan_empx100inhab_1970s  finan_rel exconst_1800_1830 exconst_1900_13 exconst_95_05 region colony_uk colony_iberia colony_other ww1, minmax


* Part 2. War-credit variables created with country-specific information about access (Reinhart and Rogoff)
sutex ty_war_and_external_kap_access ty_war_and_external_default if rr_sample == 1, minmax

* Part 3. War-Credit variables created with COW data
use "data_for_COW_full_sample.dta", clear
sutex total_years_war_and_stop_4y total_years_war_and_flow_4y, minmax


*************************************
* TABLE A-7
*************************************

* Required Stata package: listtex

use "data_for_main_analysis.dta", clear 
sort country
* Copy-paste code into latex file
listtex country total_years_war_and_stop_4y total_years_war_and_flow_4y, type rstyle(tabular) head("\begin{tabular}{rrr}" `"\textit{Country}&\textit{War and Flow}&\textit{War and Stop}\\"') foot("\end{tabular}")



********************************************
* TABLE A-8
********************************************

use "data_for_main_analysis.dta", clear 

*** B1: War-years without credit access 

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_A_8.tex", replace dec(3) 

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_8.tex", append dec(3) 


*** B2: War-years with credit access

* Column 3
reg avg_pit_95_05 total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom", r
outreg2 using "Tables/table_A_8.tex", append dec(3) 

* Column 4
reg avg_pit_95_05 total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_8.tex", append dec(3) 



*******************************************
* TABLE A-9
*******************************************

use "data_for_main_analysis.dta", clear 

**** Column 1. Drop Eye-ball outliers in partial regression plots in Figure 2 in the main text. 
reg avg_pit_95_05   total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom" & country != "Russia" & country != "France" & country != "Georgia", r
outreg2 using "Tables/table_A_9.tex", replace dec(3) 


**** Column 2: Drop Outliers based on Cook's distance

* Step 1: Compute Cook's distance

reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom"

* The convention cut-off point is 4/n.
	predict d, cooksd
	gen outlier = 1 if d>4/106 & d !=.
	list country if outlier == 1

* Step 2: Rerun with outliers based on Cook's distance	
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom" & outlier!=1, r
outreg2 using "Tables/table_A_9.tex", append dec(3) 



**********************************************
* TABLE A-10
**********************************************

use "data_for_main_analysis.dta", clear 

* Column 1. Drop Colony FE
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y  pop_dens_1820 oil_producer near_coast desert i.region if country!="United Kingdom" , r
outreg2 using "Tables/table_A_10.tex", replace dec(3) 

* Column 2. Drop Region FE
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y  pop_dens_1820 oil_producer near_coast desert colony_uk colony_iberia colony_other if country!="United Kingdom" , r
outreg2 using "Tables/table_A_10.tex", append dec(3) 

* Column 3. Drop Colony and Region FE
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y  pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom" , r
outreg2 using "Tables/table_A_10.tex", append dec(3) 




**********************************************
* TABLE A-11
**********************************************

* Column 1. Foundational OECD economies excluded
use "data_for_main_analysis.dta", clear 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert state if greatpower ==0 & oecd == 0 & country!="United Kingdom", r
outreg2 using "Tables/table_A_11.tex", replace dec(3) 


* Column 2. Tentative Matches + Putterman Index of State History
use "data_for_main_analysis_with_tentative.dta", clear 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower state if country!="United Kingdom", r
outreg2 using "Tables/table_A_11.tex", append dec(3) 

* Column 3. Tentative Matches + Census 1820
use "data_for_main_analysis_with_tentative.dta", clear 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_A_11.tex", append dec(3) 

* Column 4. Federal state + Putterman Index of State History
use "data_for_main_analysis.dta", clear 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower state fede if country!="United Kingdom", r
outreg2 using "Tables/table_A_11.tex", append dec(3) 

* Column 5. Federal states + Inital State Capacity
use "data_for_main_analysis.dta", clear 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 fede if country!="United Kingdom", r
outreg2 using "Tables/table_A_11.tex", append dec(3) 


**********************************************
* TABLE A-12
**********************************************

* This test requires estimation commands for multi-way clustered standard errors as in Cameron, Gelbach and Miller (2010 Journal of Business and Economic Statistics), extended in Esarey and Menger (2017, Political Science Research and Methods).

* Step 1: Download cgmreg ado file from https://sites.google.com/site/judsoncaskey/data

* Step 2: Once downloaded, copy the cgmreg ado and hlp files in your personal ado-directory. To locate that directory, first, type "personal" in Stata and note the location of your personal ado-directory. Second, copy-pasted cgmreg.ado and cgmreg.hlp into the personal ado-directory.

* Step 3: Type "findit clustse" in Stata and install the package. 

* Step 4: Type "findit unique" in Stata and install the package. You are ready to go. 

use "data_for_main_analysis.dta", clear 

drop if country=="United Kingdom"

* Simpler labels
gen stop = total_years_war_and_stop_4y
gen flow = total_years_war_and_flow_4y

tabulate region, generate(dregion)

* Required Stata package: clustse

* Model 1. Wild Bootstrap - Census
clustse reg avg_pit_95_05 stop flow dregion2 dregion3 dregion4 dregion5 dregion6 colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast, cluster(region) method(wild) reps(500)
outreg2 using "Tables/table_A_12.tex", replace dec(3) 

* Model 2. Wild Bootstrap - Great Power
clustse reg avg_pit_95_05 stop flow dregion2 dregion3 dregion4 dregion5 dregion6 colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast greatpower, cluster(region) method(wild) reps(500)
outreg2 using "Tables/table_A_12.tex", append dec(3) 

* Model 3. Wild Bootstrap - State
clustse reg avg_pit_95_05 stop flow dregion2 dregion3 dregion4 dregion5 dregion6 colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert state, cluster(region) method(wild) reps(500)
outreg2 using "Tables/table_A_12.tex", append dec(3) 

* Model 4. Wild Bootstrap - Census
clustse reg avg_pit_95_05 stop flow dregion2 dregion3 dregion4 dregion5 dregion6 colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast census_1820, cluster(region) method(wild) reps(500)
outreg2 using "Tables/table_A_12.tex", append dec(3) 



*******************************
* TABLE A-13
*******************************

use "data_for_main_analysis.dta", clear 

* Create flow/stop vars to speed up table formatting

gen flow = ty_war_and_flow_4y_no10
gen stop = ty_war_and_stop_4y_no10
* Column 1. Drop 1910 Stock Market Crisis
reg avg_pit_95_05 stop flow i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist  if country!="United Kingdom", r
drop flow stop
outreg2 using "Tables/table_A_13.tex", replace dec(3) 

* Column 2. Drop 1873 crises, not considered in Reinhart and Rogoff
gen flow = ty_war_and_flow_4y_no73
gen stop = ty_war_and_stop_4y_no73
reg avg_pit_95_05 stop flow i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower  statehist  if country!="United Kingdom", r
drop flow stop
outreg2 using "Tables/table_A_13.tex", append dec(3) 

* Column 3. Longer Window: 5 years
gen flow = total_years_war_and_flow_5y
gen stop = total_years_war_and_stop_5y
reg avg_pit_95_05 stop flow i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist if country!="United Kingdom", r
drop flow stop
outreg2 using "Tables/table_A_13.tex", append dec(3) 

* Column 4. Longer Window: 6 years
gen flow = total_years_war_and_flow_6y
gen stop = total_years_war_and_stop_6y
reg avg_pit_95_05 stop flow i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist if country!="United Kingdom", r
drop flow stop
outreg2 using "Tables/table_A_13.tex", append dec(3) 



*******************************
* TABLE A-14
*******************************

use "data_for_main_analysis.dta", clear 

* Analysis limited to Reinhart and Rogoff sample, rr_sample=1, from which default data is drawn.

* Model 1
reg avg_pit_95_05 years_external i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if rr_sample == 1, r
outreg2 using "Tables/table_A_14.tex", replace dec(3) 

* Model 2
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if rr_sample == 1, r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 3
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default  i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if rr_sample == 1, r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 4
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if rr_sample == 1, r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 5 
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert net_war_abroad if rr_sample == 1, r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 6
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert cloddeathsqkm if rr_sample == 1, r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 7
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ethfrac if rr_sample == 1,   r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 8
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert n_civil if rr_sample == 1,   r
outreg2 using "Tables/table_A_14.tex", append dec(3) 

* Model 9 
reg avg_pit_95_05 ty_war_and_external_default ty_war_and_external_kap_access total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ww1 if rr_sample == 1,   r
outreg2 using "Tables/table_A_14.tex", append dec(3) 




*******************************
* TABLE A-15
*******************************

* Analysis limited to Reinhart and Rogoff sample, rr_sample=1, from which default status data is drawn.

use "data_for_main_analysis.dta", clear 

* Column 1
gen flow = ty_war_and_either_kap_access
reg avg_pit_95_05 ty_war_and_either_default flow total_years_default  i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if rr_sample == 1, r 
drop flow
outreg2 using "Tables/table_A_15.tex", replace dec(3) 

* Column 2
gen flow = ty_war_and_either_kap_access
reg avg_pit_95_05 ty_war_and_either_default flow total_years_default  i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if rr_sample == 1, r
drop flow
outreg2 using "Tables/table_A_15.tex", append dec(3) 

* Column 3
gen flow = ty_war_and_either_kap_access
reg avg_pit_95_05 ty_war_and_either_default flow total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert net_war_abroad if rr_sample == 1, r
drop flow
outreg2 using "Tables/table_A_15.tex", append dec(3) 

* Column 4
gen flow = ty_war_and_external_kap_access
reg avg_pit_95_05 ty_war_and_default_no_monet ty_war_and_default_with_monet flow total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if rr_sample == 1, r
drop flow
outreg2 using "Tables/table_A_15.tex", append dec(3) 

* Column 5
gen flow = ty_war_and_external_kap_access
reg avg_pit_95_05 ty_war_and_default_no_monet ty_war_and_default_with_monet  flow total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if rr_sample == 1, r
drop flow
outreg2 using "Tables/table_A_15.tex", append dec(3) 

* Column 6
gen flow = ty_war_and_external_kap_access
reg avg_pit_95_05 ty_war_and_default_no_monet ty_war_and_default_with_monet  flow total_years_default i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert net_war_abroad if rr_sample == 1, r
drop flow
outreg2 using "Tables/table_A_15.tex", append dec(3) 


*******************************
* TABLE A-16
*******************************


use "data_for_main_analysis.dta", clear 

* Note: Fewer controls because of small N 

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower exconst_1800_1830 if country!="United Kingdom", r
outreg2 using "Tables/table_A_16.tex", replace dec(3)

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower exconst_1800_1850 if country!="United Kingdom", r
outreg2 using "Tables/table_A_16.tex", append dec(3)

* Column 3
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower democracy_1800_1850 if country!="United Kingdom", r
outreg2 using "Tables/table_A_16.tex", append dec(3)

* Column 4
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower local_dem if country!="United Kingdom", r
outreg2 using "Tables/table_A_16.tex", append dec(3)

* Column 5
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower democratization_1858_vanhanen if country!="United Kingdom", r
outreg2 using "Tables/table_A_16.tex", append dec(3)



*******************************
* TABLE A-17
*******************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert rugged if country!="United Kingdom", r
outreg2 using "Tables/table_A_17.tex", replace dec(3)

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert land_area_scaled if country!="United Kingdom", r
outreg2 using "Tables/table_A_17.tex", append dec(3)

* Column 3
gen ln_land_area_scaled = ln(land_area_scaled)
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ln_land_area_scaled if country!="United Kingdom", r
outreg2 using "Tables/table_A_17.tex", append dec(3)




*******************************
* TABLE A-18
*******************************


use "data_for_main_analysis.dta", clear 

* Not augmented VAT variable
reg non_augmented_avg_vat_95_05  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom",  r
outreg2 using "Tables/table_A_18.tex", replace dec(3)

* Augmented 
reg avg_vat_95_05  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if country!="United Kingdom",  r
outreg2 using "Tables/table_A_18.tex", append dec(3)

* Augmented + Census
reg avg_vat_95_05  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if country!="United Kingdom",  r
outreg2 using "Tables/table_A_18.tex", append dec(3)

* Augmented + State History
reg avg_vat_95_05  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehis if country!="United Kingdom",  r
outreg2 using "Tables/table_A_18.tex", append dec(3)



*******************************
* TABLE A-19
*******************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert share_alliance_uk share_alliance_fr share_alliance_ger share_alliance_usa greatpower census_1820 if country!="United Kingdom", r
outreg2 using "Tables/table_A_19.tex", replace dec(3) 

* Column 2 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert share_alliance_uk share_alliance_fr share_alliance_ger share_alliance_usa greatpower statehist if country!="United Kingdom", r
outreg2 using "Tables/table_A_19.tex", append dec(3) 


* Column 3
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower  census_1820 if country!="United Kingdom" & colony_uk==0, r
outreg2 using "Tables/table_A_19.tex", append dec(3) 

* Column 4
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist if country!="United Kingdom" & colony_uk==0, r
outreg2 using "Tables/table_A_19.tex", append dec(3) 


********** Notice Dataset Change

use "data_for_main_analysis_nonBritishwar.dta", clear 

* Column 5
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower  census_1820 if country!="United Kingdom" , r
outreg2 using "Tables/table_A_19.tex", append dec(3) 

* Column 6
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist if country!="United Kingdom", r
outreg2 using "Tables/table_A_19.tex", append dec(3) 


*******************************
* TABLE A-20
*******************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg avg_pit_95_05 total_years_ongoingwar_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower if greatpower ==0 & country!="United Kingdom" & country!= "Netherlands" & country!= "United States of America" & country != "Canada" & country!="Japan", r
outreg2 using "Tables/table_A_20.tex", replace dec(3)

* Column 2. Ongoing war + Census Date + No Great Power, no Financial Capitals
reg avg_pit_95_05 total_years_ongoingwar_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 if greatpower ==0 & country!="United Kingdom" & country!= "Netherlands" & country!= "United States of America" & country != "Canada" & country!="Japan", r
outreg2 using "Tables/table_A_20.tex", append dec(3)

* Column 3. Ongoing war + State Antiquity + No Great Power, no Financial Capitals
reg avg_pit_95_05 total_years_ongoingwar_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower statehist05v3 if greatpower ==0 & country!="United Kingdom" & country!= "Netherlands" & country!= "United States of America" & country != "Canada" & country!="Japan", r
outreg2 using "Tables/table_A_20.tex", append dec(3)


*******************************
* TABLE A-21
*******************************

use "data_for_analysis_reduced_form.dta", clear 

* Islands occupied by one country only. These cases have no neighbors and are excluded from analysis
gen island = 0 
replace island = 1 if country == "Australia"
replace island = 1 if country == "Iceland"
replace island = 1 if country == "Madagascar"
replace island = 1 if country == "Philippines"
replace island = 1 if country == "New Zealand"
replace island = 1 if country == "Japan"

* Column 1
eststo reduced_form_small: reg avg_pit_95_05 total_neig_war_and_stop_uk_4y total_neig_war_and_flow_uk_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if island == 0 & country!="United Kingdom", r
outreg2 using "Tables/table_A_21.tex", replace dec(3)

* Column 2
eststo reduced_form_big: reg avg_pit_95_05 total_neig_war_and_stop_uk_4y total_neig_war_and_flow_uk_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 statehist05v3  if island == 0 & country!="United Kingdom", r
outreg2 using "Tables/table_A_21.tex", append dec(3)



*******************************
* TABLE A-22
*******************************

use "data_for_main_analysis.dta", clear 

* Column 1 
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert democracy_95_05 statehist greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_22.tex", replace dec(3) 

* Column 2
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert avg_gov_size_95_05 statehist greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_22.tex", append dec(3) 

* Column 3
gen ln_avg_gdp_cap_95_05 = ln(avg_gdp_cap_95_05)
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert ln_avg_gdp_cap_95_05 statehist greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_22.tex", append dec(3) 

* Column 4
reg avg_pit_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert avg_trade_95_05 statehist greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_22.tex", append dec(3) 


***************************************************************
* TABLE A-23												
***************************************************************


use "TCSD_structure.dta", replace

* Flexible Polynomial, assuming that countries are at "risk" of adoption a modern census since it is first implemented in Sweden in 1751 (earliest adopter).
	gen time_1 = year - 1751
	gen time_2 = time_1*time_1
	gen time_3 = time_1*time_1*time_1

* TSCSD: drop cases beyond adoption date
	gen censor = year if year == first_census
	bysort country: egen tool = max(censor)
	bysort country: drop if year>tool
	sort country year
	drop censor tool
	
gen inter_state_X_stop_4y = inter_state*stop_4y

probit census inter_state stop_4y inter_state_X_stop_4y ln_ipol_cgdpp oil_producer i.region time_1 time_2 time_3 colony_uk colony_iberia colony_other, r
lincom inter_state + inter_state_X_stop_4y
outreg2 using "Tables/table_A_23.tex", replace dec(3) 

probit census inter_state stop_4y inter_state_X_stop_4y ln_ipol_cgdpp oil_producer i.region time_1 time_2 time_3 colony_uk_timevarying colony_iberian_timevarying colony_other_timevarying, r
lincom inter_state + inter_state_X_stop_4y
outreg2 using "Tables/table_A_23.tex", append dec(3) 


*******************************
* TABLE A-24
*******************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg ln_rail_km_1913 total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert land_area_scaled rugged tropical ln_rail_km_1850 if country!="United Kingdom", r
outreg2 using "Tables/table_A_24.tex", replace dec(3) 

* Column 2
reg ln_rail_km_1913  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert land_area_scaled rugged tropical statehis statehis ln_rail_km_1850  if country!="United Kingdom", r
outreg2 using "Tables/table_A_24.tex", append dec(3) 

* Column 3
reg ln_rail_km_1913  total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert land_area_scaled rugged tropical greatpower statehis ln_rail_km_1850 if country!="United Kingdom", r
outreg2 using "Tables/table_A_24.tex", append dec(3) 


*******************************
* TABLE A-25
*******************************

* Note: These are the same models than those used to produce Figure 3. Fewer controls because of small N.

use "data_for_main_analysis.dta", clear 

* Column 1
reg nontrade_tax_45_55  total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower  if country!="United Kingdom" , r
outreg2 using "Tables/table_A_25.tex", replace dec(3) 

* Column 2
reg nontrade_tax_55_65  total_years_war_and_stop_4y total_years_war_and_flow_4y  pop_dens_1820 oil_producer colony_any near_coast greatpower if country!="United Kingdom" , r
outreg2 using "Tables/table_A_25.tex", append dec(3) 

* Column 3
reg nontrade_tax_65_75  total_years_war_and_stop_4y total_years_war_and_flow_4y  pop_dens_1820 oil_producer colony_any near_coast greatpower if country!="United Kingdom" , r
outreg2 using "Tables/table_A_25.tex", append dec(3) 

* Column 4
reg nontrade_tax_75_85  total_years_war_and_stop_4y total_years_war_and_flow_4y  pop_dens_1820 oil_producer colony_any near_coast greatpower if country!="United Kingdom" , r
outreg2 using "Tables/table_A_25.tex", append dec(3) 

* Column 5
reg nontrade_tax_85_95  total_years_war_and_stop_4y total_years_war_and_flow_4y pop_dens_1820 oil_producer colony_any  near_coast greatpower if country!="United Kingdom" , r
outreg2 using "Tables/table_A_25.tex", append dec(3) 


*******************************
* TABLE A-26
*******************************

* Note: These are the same models than those used to produce Figure 4. Fewer controls because of small N.

use "data_for_main_analysis.dta", clear 

* Column 1: Short-Run
reg exconst_1900_13  total_years_war_and_stop_4y total_years_war_and_flow_4y pop_dens_1820 near_coast oil_producer exconst_1800_1830 colony_any greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_26.tex", replace dec(3) 

* Column 2: Long-Run
reg exconst_95_05 total_years_war_and_stop_4y total_years_war_and_flow_4y pop_dens_1820 near_coast oil_producer exconst_1800_1830 colony_any greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_26.tex", append dec(3) 



*******************************
* TABLE A-27
*******************************

use "data_for_main_analysis.dta", clear 

* Column 1
reg finan_plan_empx100inhab_1970s  total_years_war_and_stop_4y total_years_war_and_flow_4y colony_any pop_dens_1820 oil_producer near_coast greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_27.tex", replace dec(3) 

* Column 2
gen finan_wage_ratio = finan_rel_wage_1970s/100
reg finan_wage_ratio total_years_war_and_stop_4y total_years_war_and_flow_4y  colony_any pop_dens_1820 oil_producer near_coast greatpower if country!="United Kingdom", r
outreg2 using "Tables/table_A_27.tex", append dec(3) 



*************************************
* FIGURE A-1
*************************************

use "data_for_main_analysis.dta", clear 

twoway (scatter tax_to_gdp_2008 taxstaff_04_10) (lfit tax_to_gdp_2008 taxstaff_04_10), ytitle(Tax Revenue as % of GDP) xtitle(Tax Staff per Thousand Capita) legend(off) graphregion(fcolor(white))

graph export "Figures/Figure_A_1.pdf", replace

*************************************
* FIGURE A-2
*************************************

* Note 1: Raster files worlddata.dta and worldcoor.dta available from http://huebler.blogspot.com.es/2012/08/stata-maps.html (Creative Commons License)

* Note 2: Required Stata package: spmap

use "worlddata.dta", clear
rename geounit country
merge 1:1 country using "location_of_war_Wimmer_Min.dta"
replace total_years_of_war = . if total_years_of_war == 0 
spmap total_years_of_war using "worldcoor.dta", id(id) fcolor(Reds2) clnumber(5) ndlabel(no war) clbreaks(0 2 5 10 15 20) 

graph export "Figures/Figure_A_2.pdf", replace

*************************************
* FIGURE A-3
*************************************

* Note 1: Raster files worlddata.dta and worldcoor.dta available from http://huebler.blogspot.com.es/2012/08/stata-maps.html (Creative Commons License)

* Note 2: Required Stata package: spmap

use "data_for_main_analysis_with_tentative_and_secession.dta", clear
keep country years_external 
save "temp1.dta", replace

**** Copy-paste the following code in the Replication materials
use "worlddata.dta", clear
rename geounit country
merge 1:1 country using "temp1.dta"
replace years_external = . if years_external == 0 
spmap years_external using worldcoor.dta, id(id) fcolor(Blues)  clnumber(7)  clbreaks(0 2 5 10 15 25 50)   ndlabel(no war)

graph export "Figures/Figure_A_3.pdf", replace


*******************************************
* FIGURE A-4
*******************************************

use "data_for_main_analysis.dta", clear 

quietly reg avg_pit_95_05   total_years_war_and_stop_4y total_years_war_and_flow_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if country!="United Kingdom" & country != "Russia" & country != "France" & country != "Georgia", r

avplot total_years_war_and_stop_4y, mlabel(country) xtitle("Residuals from Regressing" "# Years at War while Credit Stops on Controls") ytitle("Residuals from Regressing" "PIT as % of GDP on Controls") graphregion(color(white))

graph export "Figures/Figure_A_4a.pdf", replace

avplot total_years_war_and_flow_4y, mlabel(country)  xtitle("Residuals from Regressing" "# Years at War while Credit Flows on Controls") ytitle("Residuals from Regressing" "PIT as % of GDP on Controls") graphregion(color(white))

graph export "Figures/Figure_A_4b.pdf", replace


*******************************
* FIGURE A-5
*******************************

use "data_for_analysis_reduced_form.dta", clear 

gen island = 0 
replace island = 1 if country == "Australia"
replace island = 1 if country == "Iceland"
replace island = 1 if country == "Madagascar"
replace island = 1 if country == "Philippines"
replace island = 1 if country == "New Zealand"
replace island = 1 if country == "Japan"

* Note: Islands have no neighbors; excluded from test.

eststo reduced_form_small: quiet reg avg_pit_95_05 total_neig_war_and_stop_uk_4y total_neig_war_and_flow_uk_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert if island == 0 & country!="United Kingdom", r

eststo reduced_form_full: quiet reg avg_pit_95_05 total_neig_war_and_stop_uk_4y total_neig_war_and_flow_uk_4y i.region colony_uk colony_iberia colony_other pop_dens_1820 oil_producer near_coast desert greatpower census_1820 statehist05v3  if island == 0 & country!="United Kingdom", r

coefplot reduced_form_small reduced_form_full, keep(total_neig_war_and_flow_uk_4y total_neig_war_and_stop_uk_4y) yline(0, lcolor(gs13) lpattern(dash)) levels(90) vertical ytitle("Marginal Effect on" "Long-Run Income Tax as % of GDP") graphregion(color(white)) 


graph export "Figures/Figure_A_5.pdf", replace


*******************************
* FIGURE A-6
*******************************

use "data_for_main_analysis.dta", clear 

* Figure A-6(a)
eststo finance_size: reg finan_plan_empx100inhab_1970s total_years_war_and_flow_4y total_years_war_and_stop_4y colony_any pop_dens_1820 oil_producer near_coast greatpower if country!="United Kingdom", r

coefplot finance_size, keep( total_years_war_and_flow_4y total_years_war_and_stop_4y) yline(0, lcolor(gs13) lpattern(dash)) levels(90) vertical ytitle("Marginal Effect on the Size" "of the Financial Administration" "in the late 1970s") graphregion(color(white)) 

graph export "Figures/Figure_A_6a.pdf", replace


* Figure A-6(b)
gen finan_wage_ratio = finan_rel_wage_1970s/100
eststo finance_wage: reg finan_wage_ratio total_years_war_and_flow_4y total_years_war_and_stop_4y colony_any pop_dens_1820 oil_producer near_coast greatpower if country!="United Kingdom", r

coefplot finance_wage, keep( total_years_war_and_flow_4y total_years_war_and_stop_4y) yline(0, lcolor(gs13) lpattern(dash)) levels(90) vertical ytitle("Marginal Effect on Wage Premium" "of the Financial Administration"" in the late 1970s") graphregion(color(white)) 

graph export "Figures/Figure_A_6b.pdf", replace



*******************************
* FIGURE A-7
*******************************

use "war_default_dataset.dta", clear

bysort year: egen year_wars = total(external_war)

twoway (scatter year_wars year, msymbol(smcircle)) (line year_wars year), ytitle(# wars) xtitle("") xscale(range(1815 1915)) xline(1825 1837 1847 1857 1865 1873 1890 1910, lpattern(tight_dot) lcolor(black)) xlabel(1815(20)1915) xmtick(1815(20)1915) legend(off) graphregion(fcolor(white))

graph export "Figures/Figure_A_7.pdf", replace

log close

